<template>
	<view>
		<!-- <uni-nav-bar  title="收货地址">
			
		</uni-nav-bar> -->


		<!-- <view>  测试  {{pathMsg}}</view> -->

		<block v-for='(item,index) in pathList'>

			<uniSwipeAction :options='options' @click='bindClick($event,index)'>



				<uni-list-item showExtraIcon>
					<view>
						<view>
							<text class="main-text-color mr-1">{{item.name}} </text>
							<text>{{item.phone}}</text>
							<text class="main-text-color"
							v-if='item.isdefault'
							>[默认]</text>
						</view>
						<view>
							{{item.path}}
						</view>
						<view>
							{{item.detailPath}}
						</view>
					</view>

				</uni-list-item>

			</uniSwipeAction>

		</block>




		<!-- <uniSwipeAction  :options='options'>
		
		
		
			<uni-list-item showExtraIcon>
				<view>
					<view>
						<text class="main-text-color mr-1">summer </text>
						<text>158xxxxxxxxx</text>
					</view>
					<view>
						湖北省 武汉市 武昌区
					</view>
					<view>
						光谷联峰广场 对面 天域足道
					</view>
				</view>
		
			</uni-list-item>
		
		</uniSwipeAction> -->




	</view>
</template>

<script>
	import uniNavBar from '../../components/uni-ui/uni-nav-bar/uni-nav-bar.vue'
	import uniListItem from "@/components/uni-ui/uni-list-item/uni-list-item.vue"

	import uniSwipeAction from "@/components/uni-ui/uni-swipe-action/uni-swipe-action.vue"


	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		components: {
			uniNavBar,
			uniListItem,
			uniSwipeAction
		},

		computed: {
			...mapState({
				pathMsg: state => state.path.msg,
				pathList: state => state.path.list
			})
		},
		data() {
			return {

				options: [{
					text: '修改',
					style: {
						backgroundColor: '#007aff'
					}
				}, {
					text: '删除',
					style: {
						backgroundColor: '#dd524d'
					}
				}]

			}
		},
		methods: {
			...mapMutations(['delPath']),

			bindClick(e, myIndex) {
				console.log('e', e)
				console.log('myIndex', myIndex)


				if (e.index == 0) { //修改
					alert('修改')
					
					
					// {
					// 	name:"summer",
					// 	phone:"158****531",
					// 	path:"湖北省 武汉市 武昌区",
					// 	detailPath:"光谷联峰广场 对面 天域足道",
					// 	isdefault:false
					// },
					
					
					let  currentPath=this.pathList[myIndex];
					currentPath.myindex=myIndex
					
					console.log(currentPath)
					let str=JSON.stringify(currentPath)
					
				    uni.navigateTo({
				    	url:'../user-path-edit/user-path-edit?pathItem='+ str
				    })	
					
					




				} else { //删除

					uni.showModal({
						content: '要删除该收货地址吗?',
						success: (res) => {
							if (res.confirm) {
								this.delPath(myIndex)
								uni.showToast({
									title: '删除成功'
								})
							}
						}
					})


				}



			}

		},
		
		// 类似于生命周期   
		onNavigationBarButtonTap(e) {
			// alert(e)
			// console.log(e)
			if(e.index==0) {
				uni.navigateTo({
					url:'../user-path-edit/user-path-edit'
				})
			}
		}
	}
</script>

<style>

</style>
